<script type="text/javascript">
    var pipelines = <%== scope[:pipeline_stages_json] %>;

    jQuery("<%= scope[:selector] -%>").autocomplete(pipelines, {
        minChars: 0,
        width: 400,
        matchContains: "word",
        autoFill: false,
        formatItem: function(row, i, max) {
            return  row.pipeline + " <span class='autocomplete_stage'>[" + row.stage + "]</span>";
        },
        formatMatch: function(row, i, max) {
            return row.pipeline + " " + row.stage;
        },
        formatResult: function(row) {
            return row.pipeline + " [" + row.stage + "]";
        }
    });

</script>